import { transform, fromLonLat } from 'ol/proj'

// 坐标系转换
export function coordinateTransform(coordinate: number[], isReverse = false) {
  if(isReverse) {
    return transform(coordinate, "EPSG:3857", "EPSG:4326")
  }
  return transform(coordinate, "EPSG:4326", "EPSG:3857")
}

export function coordinateFromLonLat(coordinate: number[]) {
  return fromLonLat(coordinate)
}

export const getImageUrl = (name: string) => new URL(`../assets/${name}`, import.meta.url).href